package com.vicarica.entity;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateUtil {

	public static String mmdd="MM/dd";
	public static String mmddyyyy="MM/dd/yyyy";
	
	private static SimpleDateFormat mmddFormat=new SimpleDateFormat(mmdd);
	private static SimpleDateFormat mmddyyyyFormat=new SimpleDateFormat(mmddyyyy);
	
	public static Date getFormattedDate(String dateString, String format) {

		SimpleDateFormat sdformat=createSimpleDateFormat(format);
		Date date=null;
		try {
			date = sdformat.parse(dateString);
		} catch (ParseException e) {
			//e.printStackTrace();
			System.out.println("mute");
		}
		return date;
		
	}

	private static SimpleDateFormat createSimpleDateFormat(String format) {
		if (mmdd.equals(format)){
			return mmddFormat;
		}
		else if (mmddyyyy.equals(format)){
			return mmddyyyyFormat;
		}
		return null;
	}
	
	
}
